<?php

declare(strict_types=1);
/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://hyperf.wiki
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
 */
use Hyperf\HttpServer\Router\Router;

Router::addRoute(['GET', 'POST', 'HEAD'], '/', 'App\Controller\IndexController@index');

Router::get('/favicon.ico', function () {
    return '';
});

Router::post(
    '/sendCode',
    [\App\Controller\UserLogin::class, 'sendPhoneCode'],
    [
        'middleware' => [\App\Middleware\SendCodeMiddleware::class],
    ]
);
Router::post(
    '/userLogin',
    [\App\Controller\UserLogin::class, 'login'],
    [
        'middleware' => [\App\Middleware\UserLoginMiddleware::class],
    ]
);

Router::post('/upload', [\App\Controller\Upload::class, 'index']);
Router::post('/uploadFile', [\App\Controller\Upload::class, 'qiniuUpload']);

Router::addGroup('/v1', function () {
    Router::get('/getUserInfo', [\App\Controller\v1\User::class, 'getUserInfo']);
    Router::get('/getFollowList', [\App\Controller\v1\User::class, 'getFollowList']);
    Router::get('/getFollowedList', [\App\Controller\v1\User::class, 'getFollowedList']);
    Router::post('/addFollow', [\App\Controller\v1\User::class, 'addFollow']);
    Router::post('/addBlock', [\App\Controller\v1\User::class, 'addBlock']);
    Router::post('/cancalFollow', [\App\Controller\v1\User::class, 'cancalFollow']);
    Router::post('/cancelBlock', [\App\Controller\v1\User::class, 'cancelBlock']);

    Router::post('/addDiary', [\App\Controller\v1\Diary::class, 'addDiary']);
    Router::post('/deleteDiary', [\App\Controller\v1\Diary::class, 'deleteDiary']);
    Router::get('/getDiaryInfo', [\App\Controller\v1\Diary::class, 'getDiaryInfo']);
}, [
    'middleware' => [\App\Middleware\AuthMiddleware::class],
]);

//websocket路由
Router::addServer('ws', function () {
    Router::get('/', 'App\Controller\ws\WebSocket');
});
Router::post('/bindUser', [\App\Controller\ws\WebSocket::class, 'bindUser']);
Router::post('/pushNotice', [\App\Controller\ws\WebSocket::class, 'pushNotice']);
